package com.xwtec.juc.c_005;

/**
 * @Author: zt
 * @Date: 2021/3/19 16:11
 */
public class T implements Runnable {


    private int count = 100;
    @Override
    public synchronized void run() { //synchronized 既保证原子性又保证可见性
        count--;
        System.out.println(Thread.currentThread().getName()+",count="+count);
    }

    public static void main(String[] args) {
        T t = new T();
        for (int i = 0; i <100 ; i++) {
            new Thread(t,"Thread"+i).start();
        }
    }

}
